﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework;

namespace chemicall
{
    public class ChooseLevelMenu : MenuScreen
    {
        GameManager gM;
        public ChooseLevelMenu()
            : base("Selection des niveaux")
        {
            gM = GameManager.getInstance();
            MenuItem niveau1Entry = new MenuItem("Niveau 1");         

            niveau1Entry.Selected += Niveau1Selected;
            MenuEntries.Add(niveau1Entry);

            if (gM.tNiveau[0])
            {
                MenuItem niveau2Entry = new MenuItem("Niveau 2");
                niveau2Entry.Selected += Niveau2Selected;
                MenuEntries.Add(niveau2Entry);
            }
            MenuItem backMenuEntry = new MenuItem("Retour");
            backMenuEntry.Selected += BackMenuSelected;
            MenuEntries.Add(backMenuEntry);
        }

        void Niveau1Selected(object sender, System.EventArgs e)
        {
            this.ScreenManager.LastScreen = this;
            ScreenManager.AddScreen(new PlayMenu(), PlayerIndex.One);
            ScreenManager.AddScreen(LevelManager.getInstance(), PlayerIndex.One);
            LevelManager.getInstance().LoadLevel(1);
        }

        void Niveau2Selected(object sender, System.EventArgs e)
        {
            if (gM.tNiveau[0])
            {
                this.ScreenManager.LastScreen = this;
                ScreenManager.AddScreen(new OptionMenu(), PlayerIndex.One);
                ScreenManager.AddScreen(LevelManager.getInstance(), PlayerIndex.One);
                LevelManager.getInstance().LoadLevel(2);
            }
            else
            {
                this.ScreenManager.LastScreen = this;
                ScreenManager.AddScreen(new ChooseLevelMenu(), PlayerIndex.One);
            }
        }

        void BackMenuSelected(object sender, System.EventArgs e)
        {
            ScreenManager.AddScreen(this.ScreenManager.LastScreen, PlayerIndex.One);
            this.ScreenManager.LastScreen = this;
        }
    }
}
